package com.shujia.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo15CoGroup {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
    conf.setAppName("Demo15CoGroup")
    conf.setMaster("local")

    val sc: SparkContext = new SparkContext(conf)

    val kvRDD1: RDD[(String, Int)] = sc.parallelize(List[(String, Int)]("k1" -> 1, "k2" -> 2, "k3" -> 3))
    val kvRDD2: RDD[(String, Int)] = sc.parallelize(List[(String, Int)]("k2" -> 22, "k3" -> 33, "k4" -> 44))

    // 相当于fullOuterJoin操作
    kvRDD1.cogroup(kvRDD2).foreach(println)



  }

}
